package lib;

import java.io.InputStream;
import java.util.Properties;

public class Configuration {

    static Properties properties = null;
    static String env = null;
    static {
        try {
            properties = new Properties();
            InputStream in = Configuration.class.getClassLoader().getResourceAsStream("application.conf");
            properties.load(in);

            env = properties.getProperty("env");
            if (env.equals("${env}")) {
                env = "dev";
            }

            System.out.println("evn:" + env);
            System.out.println("properties loaded:" + properties);
            in.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static String get(String key) {
        String realKey = "%" + env + "." + key;
        return properties.getProperty(realKey);
    }

    public static boolean isTest() {
        return env.equals("test");
    }
}
